# 构建阶段
FROM node:20-slim AS builder

WORKDIR /app

COPY package*.json ./
RUN npm install --production

# 运行阶段
FROM node:20-slim

WORKDIR /app

# 复制依赖
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./

# 复制应用代码
COPY . .

# 设置环境变量
ENV NODE_ENV=production \
    PORT=80

# 暴露端口
EXPOSE 80

# 启动服务
CMD ["npm", "start"]
